const angular = require('angular');
var app = angular.module('ita-app');

app.run(['$rootScope', '$transitions', '$http', function ($rootScope, $transitions , $http) {
    $transitions.onStart({ to: 'merchant.*' }, function (trans) {
        var $state = trans.router.stateService;
            $http.get('/o2o/getLogin').then(function (response) {
                $rootScope.merchant = response.data.message;
                if (!$rootScope.merchant) {
                    $state.go('audit');
                    return;
                }
                if ($rootScope.merchant.status != '正常') {
                    $state.go('merchant.info');
                    return;
                }
            });
    });
}]);